package cn.fjc920.siaa.activitys

import android.content.Context
import android.content.Intent
import android.os.Bundle
import cn.fjc920.siaa.R
import cn.fjc920.siaa.activityutils.BaseActivity
import kotlinx.android.synthetic.main.activity_share.*

class ShareActivity : BaseActivity() {

    private lateinit var context: Context

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_share)

        init()
        initClick()
    }

    private fun init(){

        context = this
        setSupportActionBar(findViewById(R.id.share_toolbar))
        supportActionBar!!.setDisplayHomeAsUpEnabled(true)
    }

    private fun initClick(){
        share_toolbar.setNavigationOnClickListener {
            finish()
        }

        btn_share_url.setOnClickListener {
            val sendIntent = Intent().apply {
                action = Intent.ACTION_SEND
                putExtra(
                    Intent.EXTRA_TEXT,
                    "工时助手\n下载地址：http://www.fjc920.cn/Application/gszs.app"
                )
                type = "text/plain"
            }
            startActivity(Intent.createChooser(sendIntent, "分享工时助手"))
        }
    }

    companion object {
        fun actionStart(context:Context) {
            val intent = Intent(context,ShareActivity::class.java)
            context.startActivity(intent)
        }
    }
}